package com.zzl.boot.bigevent.controller;

import com.zzl.boot.bigevent.pojo.category;
import com.zzl.boot.bigevent.pojo.result;
import com.zzl.boot.bigevent.pojo.tag;
import com.zzl.boot.bigevent.service.categoryService;
import com.zzl.boot.bigevent.service.tagService;
import jakarta.validation.constraints.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/tag")
@Validated
public class tagController {
    @Autowired
    private tagService service;
    //添加标签
    @PostMapping("/add")
    public result addTag(String tagName) {
        service.add(tagName);
        return result.success();
    }
    //获取标签列表
    @GetMapping("/list")
    public result<List<tag>> getAllTag() {
        List<tag> list=service.getList();
        return result.success(list);
    }
    //修改标签
    @PutMapping("/update")
    public result updateTag(@RequestBody  @Validated(tag.update.class)tag tag) {
        service.update(tag);
        return result.success();
    }
    //删除标签
    @DeleteMapping("/del")
    public result delTag(Integer id) {

        return  service.del(id);
    }
}
